#include "Example_OpenGL_View_Controller.h"
#include <sxOpenGL_DefaultCameraRenderer.h>

/* Sx library types. */
using Sx::Interface::ViewController;
using Sx::OpenGL::Graphics::Contexts::OpenGL_Context;
using Sx::QtInterface::QOpenGL_Viewport;
using Sx::OpenGL::Graphics::Objects::Rendering::OpenGL_DefaultCameraRenderer;
using Sx::Math::ORTHOGRAPHIC;
using Sx::Math::FRONT;

Example_OpenGL_View_Controller::Example_OpenGL_View_Controller(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) {
	ui.setupUi(this);

	this->openglContext = std::make_shared<OpenGL_Context>();
	this->openglViewport = new QOpenGL_Viewport(this, this->openglContext);

	this->viewController = std::make_shared<ViewController>(this->openglViewport, std::make_shared<OpenGL_DefaultCameraRenderer>(this->openglContext));
	this->viewController->initialize();

	this->openglViewport->setController(this->viewController);
}

Example_OpenGL_View_Controller::~Example_OpenGL_View_Controller() {}

void Example_OpenGL_View_Controller::resizeEvent(QResizeEvent* e) {
	this->openglViewport->resize(this->width(), this->height());
}
